package MT::Tool;
use strict;

use base 'MT';

use vars qw( $VERSION );
$VERSION = 0.041;

use MT::Log;

sub init {
    my $tool  = shift;
    my %param = @_;
    if (MT->version_number < 4) {    # check MT 3.x init is right.
        $tool->set_language('en_US');    # fix!
        $tool->read_config(\%param) or die $tool->errstr;
        $_->init_app($tool) foreach @MT::Plugins;    # right order with next?
        $tool->init_plugins(@_) or die $tool->errstr;
    } else {
        $tool->bootstrap() unless $MT::MT_DIR;
        $tool->{mt_dir}     = $MT::MT_DIR;
        $tool->{config_dir} = $MT::CFG_DIR;
        $tool->{app_dir}    = $MT::APP_DIR;
        $tool->init_callbacks();
        $tool->init_config(\%param) or die $tool->errstr;
        $tool->init_plugins(@_)     or die $tool->errstr;
        $MT::plugins_installed = 1;
        $tool->init_schema();
        $tool->run_callbacks('init_app', $tool, @_);
    }
    $tool->request->reset();    # probably not necessary but...
    $tool->request('App-Class', ref $tool);
    $tool->init_request(@_);
    $tool->run_callbacks(ref($tool) . '::init_request', $tool, @_);
    foreach (@MT::Plugins) {
        $_->init_request($tool)
          if $_->can('init_request');
    }
    $tool->{init_request} = 1;
    $tool;
}

sub init_request { }

sub run { }    # should this setup (or at least help) command line options?

1;

__END__

=head1 NAME

MT::Tool - a MT application module use for developing
command line tools.

=head1 VERSION

0.41

=head1 SYNOPSIS

 

=head1 DESCRIPTION

=head1 METHODS

=head1 AUTHOR & COPYRIGHT

MT::Tool is Copyright 2006-2007, Timothy Appnel, Appnel Internet
Solutions, LLC. http://appnel.com/

This program is free software; you can use, modify, and
redistribute it under the same terms as Perl 5.8.x itself.

See http://www.perl.com/perl/misc/Artistic.html

=cut
